package com.ease.framework.workbench.spi.impls {
	import com.ease.util.collections.MapProvider;
	import com.ease.framework.workbench.spi.IValueRepository;

	import mx.collections.ArrayCollection;

	/**
	 * 上下文环境的基础实现，用于存放数据
	 * 如有需要可以自行实现
	 *
	 *
	 */
	public class DefaultValueRepository extends MapProvider implements IValueRepository
	{
		public static const CURRENT_VALUE:String = "CURRENT_VALUE";

		public var parent:DefaultValueRepository;
		public var children:MapProvider = new MapProvider();


		public function DefaultValueRepository(parent:DefaultValueRepository = null)
		{
			super();
			this.parent = parent;
		}

		public function createSubRepository(id:String):IValueRepository
		{
			var value:DefaultValueRepository = new DefaultValueRepository(this);
			children.put(id,value);
			return value;
		}


		public function getSubRepository(id:String):IValueRepository
		{
			var value:IValueRepository = IValueRepository(children.getObject(id));
			if(value == null){
				value = createSubRepository(id);
			}
			return value;
		}

		public function getParentRepository():IValueRepository
		{
			return parent;
		}

		public function getSubRepositories():Array
		{
			return children.values();
		}

	}
}